package net.wanho.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import net.wanho.dto.InStoreDTO;
import net.wanho.entity.InStore;
import net.wanho.mapper.InStoreMapper;
import net.wanho.service.InStoreService;
import net.wanho.vo.BuyListVo;
import net.wanho.vo.InStoreVo;
import net.wanho.vo.PageVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【in_store(入库单表)】的数据库操作Service实现
* @createDate 2025-05-05 02:08:25
*/
@Service
@RequiredArgsConstructor
public class InStoreServiceImpl extends ServiceImpl<InStoreMapper, InStore> implements InStoreService{
    private final InStoreMapper inStoreMapper;

    @Override
    public PageVo<InStoreVo> getPageList(BuyListVo buyListVo, Integer pageNum, Integer pageSize) {
        IPage<InStore> page = new Page<>(pageNum, pageSize);

        List<InStoreVo> inStoreVoList = inStoreMapper.selectInStorePage(page, buyListVo);

        return new PageVo<>(
                page.getCurrent(),
                page.getSize(),
                page.getTotal(),
                page.getPages(),
                page.offset(),
                inStoreVoList
        );
    }

    @Override
    public void updatePurchaseById(InStoreDTO inStoreDTO) {
        InStore inStore = new InStore();
        BeanUtil.copyProperties(inStoreDTO, inStore);
        inStore.setIsIn("1");
        inStoreMapper.updateById(inStore);
    }
}




